package com.t235.gc.order.service.impl;

import com.t235.gc.entity.GoodsOrder;
import com.t235.gc.dao.GoodsOrderDao;
import com.t235.gc.order.service.GoodsOrderService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

/**
 * 商品订单表(GoodsOrder)表服务实现类
 *
 * @author makejava
 * @since 2021-03-24 08:45:32
 */
@Service("goodsOrderService")
public class GoodsOrderServiceImpl implements GoodsOrderService {
    @Resource
    private GoodsOrderDao goodsOrderDao;

    /**
     * 通过ID查询单条数据
     *
     * @param orderid 主键
     * @return 实例对象
     */
    @Override
    public GoodsOrder queryById(Long orderid) {
        return this.goodsOrderDao.queryById(orderid);
    }

    /**
     * 查询多条数据
     *
     * @param offset 查询起始位置
     * @param limit  查询条数
     * @return 对象列表
     */
    @Override
    public List<GoodsOrder> queryAllByLimit(int offset, int limit) {
        return this.goodsOrderDao.queryAllByLimit(offset, limit);
    }

    /**
     * 新增数据
     *
     * @param goodsOrder 实例对象
     * @return 实例对象
     */
    @Override
    public GoodsOrder insert(GoodsOrder goodsOrder) {
        this.goodsOrderDao.insert(goodsOrder);
        return goodsOrder;
    }

    /**
     * 修改数据
     *
     * @param goodsOrder 实例对象
     * @return 实例对象
     */
    @Override
    public GoodsOrder update(GoodsOrder goodsOrder) {
        this.goodsOrderDao.update(goodsOrder);
        return this.queryById(goodsOrder.getOrderid());
    }

    /**
     * 通过主键删除数据
     *
     * @param orderid 主键
     * @return 是否成功
     */
    @Override
    public boolean deleteById(Long orderid) {
        return this.goodsOrderDao.deleteById(orderid) > 0;
    }
}
